#include "..\TalkTom\stdafx.h"

#ifndef __CWGLARTK_H__
#define __CWGLARTK_H__
	
#include	<AR/config.h>
#include	<AR/video.h>
#include	<AR/param.h>
#include	<AR/ar.h>
#include	<AR/gsub_lite.h>

#include	"../MMD/VecMatQuat.h"


class cWglARTK
{
private :
	ARParam		m_sCameraParam;
	int			m_iPattID;

	ARGL_CONTEXT_SETTINGS_REF
		m_pArglSettings;

	double		m_dmatRotX[16];
	Matrix		m_matRotX;

	ARUint8		*m_pARTImage;    // the current image data

	bool		m_bMarkerFound;

	double		m_dPattWidth;
	double		m_dPattCenter[2];
	double		m_dPattTransMat[3][4];

	double		m_dViewScaleFactor;

	bool		m_bFirstTime;
public :
	cWglARTK( void );
	~cWglARTK( void );

	bool initAR( const char *szCameraParamFName, 
				 const char *szPattFName,
				 const char *szVConfFName,
				 int *pImgWidth,
				 int *pImgHeight );
	bool initArgl( void );

	bool update( void );
	void display( void );
	
	void capNextImage( void );

	void getCameraPos( Vector3 *pvec3CamPos );

	void getProjectionMat( double dMat[16] );
	void getModelViewMat( double dMat[16] );
	void addViewScaleFactor( double dAdd );

	void cleanup( void );

	inline int  getCurrentScale( void ){return m_dViewScaleFactor; }
	inline void getImageData(char** ppData){*ppData = (char*)m_pARTImage; }

	inline bool isMarkerFound( void ){return m_bMarkerFound; }
};


#endif